const mongoose = require('mongoose')
const { Schema, model } = mongoose

// 文档schema
const questionSchema = new Schema({
    __v: {
        type: Number,
        select: false
    },
    title: {
        type: String,
        required: true
    },
    description: {
        type: String,
    },
    // 关注者
    questioner: {
        type: Schema.Types.ObjectId,
        ref: 'User',
        required: true,
        select: false
    },
    // 一个问题的话题不会太多，所以在问题下设置话题字段，而不是在话题下设置问题字段
    topics: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Topic',
        }],
        select: false
    }
}, { timestamps: true })

module.exports = model('Question', questionSchema)